<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
// 参:member,num
// 一轮（member-1）位
// 二轮1后（num-2）位
//一轮减头
// num-1
// 存

// 左右为整数时>,<等于减一
function passGame(nameList,num){
    var queue=new Queue()
    for (let i = 0; i < nameList.length; i++) {
        queue.enqueue(nameList[i])
        // 加入队列
    }
    while(queue.size() >1){
        for (let i = 0; i < num-1; i++) {
            queue.enqueue(queue.dequeue())
        }
        queue.dequeue()
    }
    console.log(queue.size());
    var endName=queue.front()
    console.log(endName);

    return nameList.indexOf(endName)
}
names=[
    'a',
    'ab',
    'ag',
    'ac',
    'ad',
]
console.log(passGame(names,3));





    </script>
</body>
</html>